/**
 * Created by kangdaye on 16/6/13.
 */
app.factory('freightCache', function() {
    return{
        listTableHeader : [
            {displayName:'ID', field: 'id', width:'5%'},
            {displayName:'模版名称', field: 'name', width:'25%'},
            {displayName:'快递名称', field: 'carryWay',width:'15%'},
            {displayName:'是否包邮',width:'45%',cellTemplate:'' +
                '<div ng-if="row.inclPostage">全国包邮</div>'+
                '<div ng-if="!row.inclPostage">' +
                    '<p ng-repeat="item in row.freightRulesList" ng-if="!item.defaul">' +
                        '<span ng-repeat="item in item.region">' +
                            '{{item.name}}' +
                            '<em ng-repeat="regionItem in item.childList">{{regionItem.name}}</em>'+
                        '</span>：{{row.valuationModel == 1 ? "首件" + item.firstPiece + "元" : "首重" + item.firstWeight + "元"}}，每超过{{row.valuationModel == 1 ? item.secondPiece + "件" : item.secondWeight + "KG"}}增加{{item.secondAmount}}元。' +
                    '</p>'+
                '</div>'
            },
            {displayName:'操作',width:'15%',cellTemplate:'<div class="operation">' +
                '<a href="{{$root.prefix}}goods/freight/freightAE.html&{{row.id}}">编辑</a>' +
                '<a ng-click="evt.entity.delete(row.id)" class="ml-10 mr-10">删除</a>' +
            '</div>'
            }
        ],
        detailTableWeightHeader : [
            {displayName:'地区', width:'35%',cellTemplate:'' +
                '<div class="area">'+
                    '<div class="pr-40">' +
                        '<p ng-repeat="item in row.region">' +
                            '{{item.name}}:' +
                            '<em ng-repeat="regionItem in item.childList" ng-if="item.childList.length">{{!$index ? "" : "、"}}{{regionItem.name}}</em>'+
                            '<em ng-if="!item.childList.length">全部</em>'+
                        '</p>' +
                    '</div>' +
                    '<a href="javascript:;" class="area-update" ng-click="evt.entity.selectArea(row)">编辑</a>'+
                    '<input class="d-n" ng-model="row.region" name="regionA" validate=\'{"required" : "请选择地区"}\' ng-required="evt.entity.getData.valuationModel == 2 || !evt.entity.getData.valuationModel">'+
            '</div>'
            },
            {displayName:'首重KG',width:'10%',cellTemplate:'<input class="p-5 w-50px" ng-model="row.firstWeight" name="firstWeightC" validate=\'{"required" : "请输入首重"}\' ng-required="evt.entity.getData.valuationModel == 2 || !evt.entity.getData.valuationModel">'},
            {displayName:'首费(元)',width:'10%',cellTemplate:'<input class="p-5 w-50px" ng-model="row.firstAmount" name="firstAmountC" validate=\'{"required" : "请输入首费"}\' ng-required="evt.entity.getData.valuationModel == 2 || !evt.entity.getData.valuationModel">'},
            {displayName:'续重KG',width:'15%',cellTemplate:'<input class="p-5 w-50px" ng-model="row.secondWeight" name="secondWeightC" validate=\'{"required" : "请输入续重"}\' ng-required="evt.entity.getData.valuationModel == 2 || !evt.entity.getData.valuationModel">'},
            {displayName:'续费(元)',width:'15%',cellTemplate:'<input class="p-5 w-50px" ng-model="row.secondAmount" name="secondAmountC" validate=\'{"required" : "请输入续费"}\' ng-required="evt.entity.getData.valuationModel == 2 || !evt.entity.getData.valuationModel">'},
            {displayName:'操作',width:'15%',cellTemplate:'' +
                '<a href="javascript:;" ng-click="evt.entity.add()">新增</a>'+
                '<a href="javascript:;" class="ml-5" ng-click="evt.entity.delete($index)">删除</a>'
            }
        ],
        detailTablePieceHeader : [
            {displayName:'地区', width:'35%',cellTemplate:'' +
            '<div class="area">'+
            '<div class="pr-40">' +
            '<p ng-repeat="item in row.region">' +
            '{{item.name}}:' +
            '<em ng-repeat="regionItem in item.childList" ng-if="item.childList.length">{{!$index ? "" : "、"}}{{regionItem.name}}</em>'+
            '<em ng-if="!item.childList.length">全部</em>'+
            '</p>' +
            '</div>' +
            '<a href="javascript:;" class="area-update" ng-click="evt.entity.selectArea(row)">编辑</a>'+
            '<input class="d-n" ng-model="row.region" name="regionB" validate=\'{"required" : "请选择地区"}\' ng-required="evt.entity.getData.valuationModel == 1">'+
            '</div>'
            },
            {displayName:'首件',width:'10%',cellTemplate:'<input class="p-5 w-50px" ng-model="row.firstPiece" name="firstPieceD" validate=\'{"required" : "请输入首件"}\' ng-required="evt.entity.getData.valuationModel == 1">'},
            {displayName:'首费(元)',width:'10%',cellTemplate:'<input class="p-5 w-50px" ng-model="row.firstAmount" name="firstAmountD" validate=\'{"required" : "请输入首件"}\' ng-required="evt.entity.getData.valuationModel == 1">'},
            {displayName:'续件',width:'15%',cellTemplate:'<input class="p-5 w-50px" ng-model="row.secondPiece" name="secondPieceD" validate=\'{"required" : "请输入首件"}\' ng-required="evt.entity.getData.valuationModel == 1">'},
            {displayName:'续费(元)',width:'15%',cellTemplate:'<input class="p-5 w-50px" ng-model="row.secondAmount" name="secondAmountD" validate=\'{"required" : "请输入首件"}\' ng-required="evt.entity.getData.valuationModel == 1">'},
            {displayName:'操作',width:'15%',cellTemplate:'' +
            '<a href="javascript:;" ng-click="evt.entity.add()">新增</a>'+
            '<a href="javascript:;" class="ml-5" ng-click="evt.entity.delete($index)">删除</a>'
            }
        ],
        detailPostage : [
            {name : '包邮',inclPostage : 'true'},
            {name : '不包邮',inclPostage : 'false'}
        ],
        detailPricing : [
            {id : 1,name : '按件数'},
            {id : 2,name : '按重量',select : true}
        ]
    }
});
